package com.song.tradition.page.details

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.displayCutoutPadding
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.song.tradition.entity.BookData
import com.song.tradition.page.components.CustomTitleTopAppBar
import com.song.tradition.ui.theme.customBgColor

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun BookDetailScreen(
    navController: NavController,
    data: BookData
) {

    Scaffold(
        topBar = {

            CustomTitleTopAppBar(title = data.bookName, navClick = {
                navController.popBackStack()
            })
        }
    ) {
        Surface(
            modifier = Modifier
                .fillMaxSize()
                .padding(paddingValues = it)
        ) {

            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .background(customBgColor)
                    .verticalScroll(rememberScrollState())
                    .padding(horizontal = 16.dp, vertical = 8.dp)
            ) {

                Row(
                    Modifier
                        .height(200.dp)
                        .fillMaxWidth()
                        .padding(8.dp), horizontalArrangement = Arrangement.Center
                ) {

                    Card(
                        shape = RoundedCornerShape(10.dp),
                        modifier = Modifier.padding(2.dp),
                        elevation = CardDefaults.cardElevation(2.dp)
                    ) {
                        Image(
                            painterResource(id = data.resId),
                            contentDescription = "",
                            modifier = Modifier.fillMaxHeight(),
                            contentScale = ContentScale.FillHeight
                        )
                    }
                    Spacer(modifier = Modifier.width(8.dp))


                }

                Spacer(modifier = Modifier.height(16.dp))
                Text(text = "书籍简介：", fontSize = 22.sp, fontWeight = FontWeight.Bold)
                Spacer(modifier = Modifier.height(16.dp))
                Text(
                    text = data.description,
                    lineHeight = 30.sp,
                    modifier = Modifier.fillMaxWidth()
                )

            }
        }
    }

}